package com.wing.cabinet.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wing.cabinet.model.entity.ReceiveRecord;
import com.wing.cabinet.model.response.ReceiveRecordVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 领取记录表-Dao
 *
 * @author
 */
@Mapper
public interface ReceiveRecordDao extends BaseMapper<ReceiveRecord> {

    /**
     * 列表-app
     *
     * @param params
     *
     * @return
     */
    List<ReceiveRecordVO> list4app(@Param("params") Map<String, Object> params);

    /**
     * 分页列表-app
     *
     * @param page
     * @param params
     *
     * @return
     */
    List<ReceiveRecordVO> list4app(@Param("page") Page<ReceiveRecordVO> page, @Param("params") Map<String, Object> params);

    /**
     * 详情-app
     *
     * @param id
     *
     * @return
     */
    ReceiveRecordVO get4appById(Long id);

    /**
     * 统计组员共享授信当天的总金额
     * @param todayTime
     * @return
     */
    Double sumByTotalMoney(@Param("authorityManageId") Long authorityManageId,@Param("todayTime") String todayTime,@Param("skuCode")String skuCode);

    /**
     * 统计组员共享授信领用金额
     * @param startTime
     * @param endTime
     * @return
     */
    Double sumMoney(@Param("authorityManageId") Long authorityManageId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("skuCode")String skuCode);

    /**
     * 统计组员独立授信当天的总金额
     * @param receiverId
     * @param todayTime
     * @return
     */
    Double sumIndependentByTotalMoney(@Param("authorityManageId") Long authorityManageId,@Param("receiverId") Long receiverId,@Param("todayTime") String todayTime,@Param("skuCode")String skuCode);


    /**
     * 组员独立授信领用金额
     * @return
     */
    Double sumIndependentMoneyByReceiverId(@Param("params") Map<String, Object> params);

    /**
     * 根据条件查询组员共享当天数据
     * @param params
     * @return
     */
    ReceiveRecordVO getIntraDayReceiveRecordByParams(@Param("params") Map<String, Object> params);

    ReceiveRecordVO getReceiveRecordByParams(@Param("params") Map<String, Object> params);

    Integer sumByTotalQuantity(@Param("authorityManageId") Long authorityManageId,@Param("todayTime") String todayTime);
    Integer sumByTotalQuantityOne(@Param("authorityManageId") Long authorityManageId,@Param("todayTime") String todayTime,@Param("skuCode")String skuCode);

    Integer sumQuantity(@Param("authorityManageId") Long authorityManageId,@Param("startTime") String startTime,@Param("endTime") String endTime);
    Integer sumQuantityOne(@Param("authorityManageId") Long authorityManageId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("skuCode")String skuCode);

    Integer sumIndependentByTotalQuantity(@Param("authorityManageId") Long authorityManageId,@Param("receiverId") Long receiverId,@Param("todayTime") String todayTime);
    Integer sumIndependentByTotalQuantityOne(@Param("authorityManageId") Long authorityManageId,@Param("receiverId") Long receiverId,@Param("todayTime") String todayTime,@Param("skuCode")String skuCode);

    Integer sumIndependentQuantityByReceiverId(@Param("params") Map<String, Object> params);
}
